#pragma once

unsigned long __arch_cmpxchg(volatile void *ptr,
                             unsigned long old,
                             unsigned long new,
                             unsigned int size);
unsigned long __arch_xchg(unsigned long x, volatile void *ptr, int size);

#define arch_cmpxchg_relaxed(ptr, o, n)                        \
    ({                                                         \
        (__typeof__(*(ptr)))__arch_cmpxchg((ptr),              \
                                           (unsigned long)(o), \
                                           (unsigned long)(n), \
                                           sizeof(*(ptr)));    \
    })

#define arch_xchg_relaxed(ptr, x)                                  \
    ({                                                             \
        (__typeof__(*(ptr)))__arch_xchg((unsigned long)(x), (ptr), \
                                        sizeof(*(ptr)));           \
    })
